﻿/**
 * Peter
 * Created by: Peter Development Team
 *    http://peter.codeplex.com/
 * 
 * GNU General Public License version 2 (GPLv2)
 *    http://peter.codeplex.com/license
 *
 *  This code is provided on an AS IS basis, with no WARRANTIES,
 *  CONDITIONS or GUARANTEES of any kind.
 *
 **/

using System.ComponentModel.Composition.Hosting;
using System.Reflection;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Peter.Common.Services;
using Peter.Logic;

namespace Peter.Tests.Logic
{
   /// <summary>
   /// Test cases for the editor view model.
   /// </summary>
   [TestClass]
   public class ModelEditorTests
   {
      private CompositionContainer m_Container;

      /// <summary>
      /// Initializes before every test.
      /// </summary>
      [TestInitialize]
      public void TestInit ()
      {
         ServiceManager.Add<ITimerService, TimerService> ();
         var catalog = new AssemblyCatalog (Assembly.GetExecutingAssembly ());
         this.m_Container = new CompositionContainer (catalog);
      }

      /// <summary>
      /// Cleans up after every test.
      /// </summary>
      [TestCleanup]
      public void TestClean ()
      {
         ServiceManager.Clear ();
         this.m_Container.Dispose ();
      }

      /// <summary>
      /// Tests the editor view model's constructor.
      /// </summary>
      [TestMethod]
      public void TestModelEditorConstructor ()
      {
         var model = new ModelEditor ();
         Assert.IsNotNull (model.Editor);
         model.CloseCommand.Execute (null);
      }
   }
}
